#!/bin/bash
d=2017-04-06
types=(mousemove idle scroll init resize keydown unload click mousedown mouseup)
while [ "$d" != 2017-05-01 ]; do 
  echo $d
  date_format=$(date -d $d +"%Y%m%d")
	
  #curl -XDELETE "127.0.0.1:9200/uba-log-$date_format"
  curl -XPUT "127.0.0.1:9200/uba-log-$date_format"
  curl -XPUT 127.0.0.1:9200/uba-log-$date_format/_settings -d '{
          "index" : {
        	  "refresh_interval" : "30s",
        	  "number_of_replicas": 0
          }
  }'
  for type in ${types[@]} 
  do
	curl -XPUT "127.0.0.1:9200/uba-log-$date_format/_mapping/$type"  -d '{"properties": {"receiveTime":{"type": "date"}, "clientTime":{"type": "date"}, "serverTime":{"type": "date"}}}'
  done
  d=$(date -I -d "$d + 1 day")
done
